A single-threaded environment is a processing environment where an application is executed using a single thread. The single-threaded environment can be render-, frame-, or time-based. Example single-threaded environments include NodeJS™, Adobe FlashPlayer™, and web browsers. FIG. 1 depicts an example of a single-threaded environment. As shown, application 100 is running on a single thread of a processor to render video or other media through multiple frames (frames 101-109).
Here, application 100 detects an event 110 (e.g., a user input or mouse click) during the rendering of frame 101 and assigns workload 115 (the workload that corresponds to click event 110) to be performed in the subsequent frame, frame 102. As a result, workload 115 can be executed as frame 102 is being rendered. Unfortunately, workload 115 may take longer than the duration of frame 102 to execute, which leads to application 100 skipping frames 103 and 104 because the processing time for frame 102 extended into the processing time of frames 103 and 104 due to the processing of workload 115. Skipped frames are not rendered in the single-threaded environment and thus are not presented to the user.
Similarly, application 100 detects click event 120 during the rendering of frame 102 and assigns workload 125 (the workload that corresponds to click event 120) to be performed in a subsequent frame. Workload 125 is assigned to the next available subsequent frame, which is frame 105 since frames 103 and 104 have been skipped. As a result, application 100 executes workload 125 during the rendering of frame 105. Like workload 115, workload 125 takes longer than the duration of frame 105 to execute which leads to frames 106, 107, and 108 being skipped. Due to these large workloads, only four of the nine frames have been rendered (e.g., frames 101, 102, 105, and 109). As a result, the rendered video may appear choppy or unresponsive, which is frustrating to the user.